<?php

//header("content-type:application/json");
include 'config.php';
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die("Could not execute query");
$query = "SELECT * FROM d3 WHERE userid = 1";
//echo $query;
$result = mysqli_query($con, $query) or die("Could not get the user lex information");
$numfields = mysqli_num_fields($result);
$rows = mysqli_fetch_array($result);

$recArr = [];
while ($row = mysqli_fetch_array($result)) {
	$recArr[] = array('userid' => $row['userid'], 'context' => $row['context'],  'source' => $row['source'],  'title' => $row['title']);
//	$recArr[] = array('userid' => $row['userid']= array('context' => $row['context']),  'source' => $row['source'],  'title' => $row['title']);

//print_r($recArr);
//echo "<br>";
//print_r(json_encode($recArr));


$myArray = array(
$row["userid"],
    $userid[]= 
   $row["context"],
     $source[]= 
   $row["source"],
      $title[]= 
    json_encode($row["title"])
   
 )
;

//print_r($myArray);
//echo "<br>";
//print_r(json_encode($myArray));
//print_r(json_encode($rows));
}
function keyValue($array){
  $new_array = array($recArr);

  foreach ($array as $key => $value) {
      array_push($new_array, array(
          'name' => $key,
          'value' => is_array($value) ? keyValue($value) : $value
      ));
  }

  return $new_array;
  var_dump($new_array);
}


?>